﻿<UserControl x:Class="Mitosoft.Definitions.Views.FilesSelectionDialogView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:views="clr-namespace:Mitosoft.Definitions.Views"
             xmlns:Gestures="clr-namespace:WpfUIUtilities.Gestures;assembly=WpfUIUtilities"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:behaviors="clr-namespace:WpfUIUtilities.Behaviors;assembly=WpfUIUtilities"
             mc:Ignorable="d">

    <UserControl.InputBindings>
        <MouseBinding Gesture="{x:Static Gestures:MouseWheelDownKeyCtrlGesture.Instance}" Command="{Binding ZoomViewModel.ZoomDownCommand}"  />
        <MouseBinding Gesture="{x:Static Gestures:MouseWheelUpKeyCtrlGesture.Instance}" Command="{Binding ZoomViewModel.ZoomUpCommand}"  />
    </UserControl.InputBindings>

    <UserControl.LayoutTransform>
        <ScaleTransform 
            CenterX="0" CenterY="0"
            ScaleX="{Binding ZoomViewModel.ZoomFactor, Mode=TwoWay}"
            ScaleY="{Binding ZoomViewModel.ZoomFactor, Mode=TwoWay}"
        />
    </UserControl.LayoutTransform>
    
    <Grid>
        <StackPanel>
            <TextBlock FontSize="24" Foreground="DarkBlue" Margin="10">Select text files ...</TextBlock>

            <TextBlock Margin="10" TextWrapping="Wrap">
                Please select either one ore more text files and the order 
                the files should be displayed. Press the <Bold>Accept</Bold> button to
                operate with the selected files or press the <Bold>Cancel</Bold> button 
                to abort this dialog.
            </TextBlock>

            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <views:DirectorySelectionView 
                    Grid.Row="0" Grid.ColumnSpan="2" Margin="10" 
                    DataContext="{Binding DirectorySelectionViewModel}"
                    />

                <Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="10">

                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>

                    <Label Grid.Row="0" Grid.Column="0" Margin="10,0,0,0">Unselected directory files:</Label>
                    <Label Grid.Row="0" Grid.Column="2" Margin="10,0,0,0">All selected files:</Label>

                    <ListBox Grid.Row="1" Grid.Column="0" Margin="10" Height="200"
                        ItemsSource="{Binding UnselectedDirectoryFileNames}"
                        SelectedItem="{Binding SelectedDirectoryFile}"
                    >
                        <i:Interaction.Behaviors>
                            <behaviors:PassThroughMouseWheelBehavior />
                        </i:Interaction.Behaviors>
                        
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <!-- ReSharper disable once Xaml.BindingWithContextNotResolved -->
                                    <TextBlock Text="{Binding DisplayText}" />
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

                    <Grid Grid.Row="1" Grid.Column="1" Margin="10">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>

                        <Button Grid.Row="0" Grid.Column="0" Margin="10" Command="{Binding SelectFileCommand}">
                            <Path Width="26.8469" Height="21.5697" Stretch="Uniform" Fill="Black" Data="F1 M 26.8469,10.7846L 12.8223,0L 12.8223,6.8204L 0,6.8204L 0,14.7495L 12.8223,14.7495L 12.8223,21.5697L 26.8469,10.7846 Z "/>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="0" Margin="10" Command="{Binding UnselectFileCommand}">
                            <Path Width="26.8469" Height="21.5698" Stretch="Uniform" Fill="Black" Data="F1 M 0,10.7852L 14.0247,21.5698L 14.0247,14.7494L 26.8469,14.7494L 26.8469,6.82025L 14.0247,6.82025L 14.0247,0L 0,10.7852 Z "/>
                        </Button>
                    </Grid>

                    <ListBox Grid.Row="1" Grid.Column="2" Margin="10" Height="200"
                        ItemsSource="{Binding Path=SelectedFiles}"
                        SelectedItem="{Binding SelectedFile}">

                        <i:Interaction.Behaviors>
                            <behaviors:PassThroughMouseWheelBehavior />
                        </i:Interaction.Behaviors>
                        
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <!-- ReSharper disable once Xaml.BindingWithContextNotResolved -->
                                    <TextBlock Text="{Binding DisplayText}" ToolTip="{Binding FullPath}" />
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

                    <Grid Grid.Row="1" Grid.Column="3" Margin="10">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>

                        <Button Grid.Row="0" Grid.Column="0" Margin="10" Command="{Binding MoveUpCommand}">
                            <Path Width="21.5697" Height="26.8469" Stretch="Uniform" Fill="Black" 
                                  Data="F1 M 10.7846,0L 3.05176e-005,14.0247L 6.82043,14.0247L 6.82043,26.8469L 14.7495,26.8469L 14.7495,14.0247L 21.5698,14.0247L 10.7846,0 Z "/>
                        </Button>
                        <Button Grid.Row="1" Grid.Column="0" Margin="10" Command="{Binding MoveDownCommand}">
                            <Path Width="21.5698" Height="26.847" Stretch="Uniform" Fill="Black" 
                                  Data="F1 M 10.7852,26.8469L 21.5698,12.8223L 14.7494,12.8223L 14.7494,-3.05176e-005L 6.82028,-3.05176e-005L 6.82028,12.8223L 3.05176e-005,12.8223L 10.7852,26.8469 Z "/>
                        </Button>
                    </Grid>

                </Grid>

                <Button Grid.Row="2" Grid.Column="0" Margin="10" Command="{Binding AcceptDialogCommand}">Accept</Button>
                <Button Grid.Row="2" Grid.Column="1" Margin="10" Command="{Binding CancelDialogCommand}">Cancel</Button>
            </Grid>
        </StackPanel>
    </Grid>
</UserControl>
